<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/10/14
  Time: 17:39
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>易买网 - 首页</title>
    <link type="text/css" rel="stylesheet" href="html/css/style.css"/>
    <script type="text/javascript" src="html/scripts/function.js"></script>
</head>
<body>
<div id="header" class="wrap">
    <div id="logo"><img src="html/images/logo.gif" /></div>
    <div class="help"><a href="#" class="shopping">购物车</a>

        <a href="guestbook.jsp">留言</a></div>
    <script>
        var name =  "${sessionScope.user.username}";
        console.log(name);
        if(name==""){
            $(".help").append("<a href=\"login.jsp\">登录</a><a href=\"register.jsp\">注册</a>");
        }else{
            $(".help").append("<a href='html/LogOutServlet'>欢迎"+name+"登录，点击注销</a>")
        }
    </script>
    <div class="navbar">
        <ul class="clearfix">
            <li class="current"><a href="#">首页</a></li>
            <li><a href="#">图书</a></li>
            <li><a href="#">百货</a></li>
            <li><a href="#">品牌</a></li>
            <li><a href="#">促销</a></li>
        </ul>
    </div>
</div>
<div id="childNav">
    <div class="wrap">
        <ul class="clearfix">
            <li class="first"><a href="#">音乐</a></li>
            <li><a href="#">影视</a></li>
            <li><a href="#">少儿</a></li>
            <li><a href="#">动漫</a></li>
            <li><a href="#">小说</a></li>
            <li><a href="#">外语</a></li>
            <li><a href="#">数码相机</a></li>
            <li><a href="#">笔记本</a></li>
            <li><a href="#">羽绒服</a></li>
            <li><a href="#">秋冬靴</a></li>
            <li><a href="#">运动鞋</a></li>
            <li><a href="#">美容护肤</a></li>
            <li><a href="#">家纺用品</a></li>
            <li><a href="#">婴幼奶粉</a></li>
            <li><a href="#">饰品</a></li>
            <li class="last"><a href="#">Investor Relations</a></li>
        </ul>
    </div>
</div>
<div id="register" class="wrap">
    <div class="shadow">
        <em class="corner lb"></em>
        <em class="corner rt"></em>
        <div class="box">
            <h1>欢迎注册易买网</h1>
            <ul class="steps clearfix">
                <li class="current"><em></em>填写注册信息</li>
                <li class="last"><em></em>注册成功</li>
            </ul>
            <form id="regForm" method="post" action="UserRegServlet"
            <%--onsubmit="return checkForm(this);--%> onsubmit="return CheckRegister()"
            ">
            <table>
                <tr>
                    <td class="field">用户名：</td>
                    <td><input class="text" type="text" id="userName" name="userName" onfocus="FocusItem(this)"
                               onblur="CheckItem(this);"/><span></span> 仅支持英文和数字</td>
                </tr>
                <tr>
                    <td class="field">登录密码：</td>
                    <td><input class="text" type="password" id="passWord" name="passWord" onfocus="FocusItem(this)"
                               onblur="CheckItem(this);"/><span></span> 以字母开头,只能包含字母,数字和下划线</td>
                </tr>
                <tr style="display: none">
                    <td class="field">权限：</td>
                    <td><input class="text" type="hidden" name="poWer" value="1" onfocus="FocusItem(this)"
                               onblur="CheckItem(this);"/><span></span></td>
                </tr>
                <tr>
                    <td class="field">真实姓名：</td>
                    <td><input class="text" type="text" id="uname" name="userName" onfocus="FocusItem(this)"
                               onblur="CheckItem(this);"/><span></span> 仅支持中文字符</td>
                </tr>
                <tr>
                    <td class="field">身份证号：</td>
                    <td><input class="text" type="text" id="num" name="num" onfocus="FocusItem(this)"
                               onblur="CheckItem(this);"/><span></span></td>
                </tr>
                <tr>
                    <td class="field">性别：</td>
                    <td><input type="radio" name="sex" value="1" checked="checked"/>男 <input type="radio" name="sex"
                                                                                             value="1"/>女
                    </td>
                </tr>
                <tr id="birth">
                    <td class="field">出生日期：</td>
                    <td>
                        <select name="birthyear">
                            <option value="2000">2000</option>
                            <option value="1999">1999</option>
                        </select>年
                        <select name="birthmonth">
                            <option value="12">12</option>
                            <option value="11">11</option>
                        </select>月
                        <select name="birthday">
                            <option value="2">2</option>
                            <option value="1">1</option>
                        </select>日
                    </td>
                </tr>
                <tr>
                    <td class="field">手机号码：</td>
                    <td><input type="text" class="text" id="mobile" name="mobile" value=""/></td>
                </tr>
                <tr>
                    <td class="field">送货地址：</td>
                    <td><input type="text" class="text" name="address" value=""/></td>
                </tr>
                <td></td>
                <td><label class="ui-green"><input type="submit" name="submit" value="提交注册"/></label></td>
                </tr>
            </table>
            </form>
        </div>
    </div>
    <div class="clear"></div>
</div>
<div id="footer">
    Copyright &copy; 2010 北大青鸟 All Rights Reserved. 京ICP证1000001号
</div>

<script type="text/javascript" charset="UTF-8">

    function CheckRegister() {

        var name = document.getElementById("userName").value;
        var pwd = document.getElementById("passWord").value;
        var relname = document.getElementById("uname").value;
        var idnum = document.getElementById("num").value;
        var phonenum = document.getElementById("mobile").value;

        var cname = /^[A-Za-z0-9]+$/; //英文和数字
        var cpwd = /^[a-zA-Z]\w{5,17}$/; //密码(以字母开头，长度在6~18之间，只能包含字母、数字和下划线)
        var crealname = /^[\u4e00-\u9fa5]$/; //汉字
        var cidnum = /^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;  //身份证验证
        var cphonenum = /^13\d{9}$/; //手机号码

        if (cname.test(name) && cpwd.test(pwd) && crealname.test(relname) && cidnum.test(idnum) && cphonenum.test(phonenum)) {
            return true;
        } else {
            alert("信息有误!请仔细看注册要求并重新注册！");
            return false;
        }
    }
</script>

</body>
</html>

